package edu.chl.dat255.bluebanana.test.utils;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Window;
import android.view.WindowManager.LayoutParams;

public class WindowUtils extends Activity {
	private static Window window;
	private int brightness;
	private static Context staticContext;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		window = getWindow();

		staticContext = this;
		brightness = getIntent().getIntExtra("brightness", 100);
		
		setBrightness(brightness);
	}
	
	public static void setBrightness(int brightness) {
		Settings.System.putInt(staticContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness);  
		LayoutParams layoutparams = window.getAttributes();  
		layoutparams.screenBrightness = brightness / (float) 255;  
		window.setAttributes(layoutparams); 
	}
}
